//
// Description: 1894. 找到需要补充粉笔的学生编号
// Created by Loading on 2021/9/10.
//

#include <bits/stdc++.h>

using namespace std;

int chalkReplacer(vector<int> &chalk, int k) {
    long long sum = accumulate(chalk.begin(), chalk.end(), 0LL);
    k %= sum;
    for (int i = 0; i < chalk.size(); ++i) {
        if (chalk[i] <= k) {
            k -= chalk[i];
        } else {
            return i;
        }
    }

    return 0;
}

int main() {
    vector<int> chalk = {3, 4, 1, 2};
    int k = 25;
    int res = chalkReplacer(chalk, k);
    cout << res << endl;

    return 0;
}